﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Hr.Entity;
using Chenxin.Lib.Utility;
using Chenxin.Lib.Business;
using System.Text;

namespace Chenxin.Lib.Business.BLL
{
    /// <summary>
    /// 业务逻辑类LitigationBase 的摘要说明。
    /// </summary>
    public class LitigationBase
    {
        public LitigationBase()
        { }
        #region  成员方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Chenxin.Lib.Business.Entity.t_Business_LitigationInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Business_LitigationInfo.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.Business.Entity.t_Business_LitigationInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Business_LitigationInfo.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid RecordId)
        {
            Chenxin.Lib.Business.DAL.t_Business_LitigationInfo.Delete(RecordId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Business.Entity.t_Business_LitigationInfo GetModel(Guid RecordId)
        {
            return Chenxin.Lib.Business.DAL.t_Business_LitigationInfo.GetModel(RecordId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Business.DAL.t_Business_LitigationInfo.GetList(strWhere);
        }
        
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Business_LitigationInfo> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Business.DAL.t_Business_LitigationInfo.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Business_LitigationInfo> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Business.Entity.t_Business_LitigationInfo> modelList = new List<Chenxin.Lib.Business.Entity.t_Business_LitigationInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Business.Entity.t_Business_LitigationInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Business.Entity.t_Business_LitigationInfo();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["ContractId"].ToString() != "")
                    {
                        model.ContractId = new Guid(dt.Rows[n]["ContractId"].ToString());
                    }
                    model.ContractCode = dt.Rows[n]["ContractCode"].ToString();
                    model.HouseAddress = dt.Rows[n]["HouseAddress"].ToString();
                    if (dt.Rows[n]["AppCityId"].ToString() != "")
                    {
                        model.AppCityId = new Guid(dt.Rows[n]["AppCityId"].ToString());
                    }
                    model.AppCity = dt.Rows[n]["AppCity"].ToString();
                    if (dt.Rows[n]["AppCompanyId"].ToString() != "")
                    {
                        model.AppCompanyId = new Guid(dt.Rows[n]["AppCompanyId"].ToString());
                    }
                    model.AppCompany = dt.Rows[n]["AppCompany"].ToString();
                    if (dt.Rows[n]["AppDepartId"].ToString() != "")
                    {
                        model.AppDepartId = new Guid(dt.Rows[n]["AppDepartId"].ToString());
                    }
                    model.AppDepart = dt.Rows[n]["AppDepart"].ToString();
                    if (dt.Rows[n]["AppDate"].ToString() != "")
                    {
                        model.AppDate = DateTime.Parse(dt.Rows[n]["AppDate"].ToString());
                    }
                    if (dt.Rows[n]["LitigationMoney"].ToString() != "")
                    {
                        model.LitigationMoney = decimal.Parse(dt.Rows[n]["LitigationMoney"].ToString());
                    }
                    model.LitigationPerson = dt.Rows[n]["LitigationPerson"].ToString();
                    if (dt.Rows[n]["AddTime"].ToString() != "")
                    {
                        model.AddTime = DateTime.Parse(dt.Rows[n]["AddTime"].ToString());
                    }
                    if (dt.Rows[n]["AddEmployeeId"].ToString() != "")
                    {
                        model.AddEmployeeId = new Guid(dt.Rows[n]["AddEmployeeId"].ToString());
                    }
                    model.AddEmployee = dt.Rows[n]["AddEmployee"].ToString();
                    if (dt.Rows[n]["AddDepartId"].ToString() != "")
                    {
                        model.AddDepartId = new Guid(dt.Rows[n]["AddDepartId"].ToString());
                    }
                    model.AddDepart = dt.Rows[n]["AddDepart"].ToString();
                    if (dt.Rows[n]["Status"].ToString() != "")
                    {
                        model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
                    }
                    if (dt.Rows[n]["ApproveDepartId"].ToString() != "")
                    {
                        model.ApproveDepartId = new Guid(dt.Rows[n]["ApproveDepartId"].ToString());
                    }
                    model.ApproveDepart = dt.Rows[n]["ApproveDepart"].ToString();
                    if (dt.Rows[n]["ApproveEmployeeId"].ToString() != "")
                    {
                        model.ApproveEmployeeId = new Guid(dt.Rows[n]["ApproveEmployeeId"].ToString());
                    }
                    model.ApproveEmployee = dt.Rows[n]["ApproveEmployee"].ToString();
                    model.ApproveReason = dt.Rows[n]["ApproveReason"].ToString();
                    model.Suggestion = dt.Rows[n]["Suggestion"].ToString();
                    if (dt.Rows[n]["ApproveOprEmpId"].ToString() != "")
                    {
                        model.ApproveOprEmpId = new Guid(dt.Rows[n]["ApproveOprEmpId"].ToString());
                    }
                    model.ApproveOprEmp = dt.Rows[n]["ApproveOprEmp"].ToString();
                    if (dt.Rows[n]["ApproveOprTime"].ToString() != "")
                    {
                        model.ApproveOprTime = DateTime.Parse(dt.Rows[n]["ApproveOprTime"].ToString());
                    }
                    model.RulingMode = dt.Rows[n]["RulingMode"].ToString();
                    if (dt.Rows[n]["SettledMoney"].ToString() != "")
                    {
                        model.SettledMoney = decimal.Parse(dt.Rows[n]["SettledMoney"].ToString());
                    }
                    if (dt.Rows[n]["CurrentTrialStatus"].ToString() != "")
                    {
                        model.CurrentTrialStatus = int.Parse(dt.Rows[n]["CurrentTrialStatus"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        //*******************************************
        //功能概要       ：根据参数列表获得用户信息一览
        //参数説明       ：hsParams 参数列表
        //返回值説明     ：无
        //功能詳細       ：根据参数列表获得用户信息一览
        //作成者         ：zou.xiaochun
        //作成日         ：2010-09-28
        //*******************************************
        public DataSet GetModelListByCoditions(string strWhere, int strPageIndex, int strPageSize)
        {
            //排序
            string strOrderField = " AppDate desc";
            //欲选择字段列表 
            string FieldList = " RecordId,ContractCode,HouseAddress,AppDepart,AppDate,LitigationMoney,LitigationPerson,Status ";
            //子查询欲选择字段列表
            StringBuilder sb = new StringBuilder();
            sb.Append(" RecordId,ContractCode,HouseAddress,AppDepart,AppDate,LitigationMoney,LitigationPerson,Status ");
            //所要查询的表名
            string TableName = " t_Business_LitigationInfo ";
            return Chenxin.Lib.Business.DAL.t_Business_LitigationInfo.GetList(strPageIndex, strPageSize, strOrderField, TableName, strWhere, FieldList, sb.ToString(), true);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }
        #endregion  成员方法
    }
}
